<!DOCTYPE html>
<html>
<head>
	<title>Socket IO example</title>
</head>
<body>
<div id="console"></div>
<script src="/socket.io/socket.io.js"></script>
<script>
	let cd = document.getElementById("console");
	function ptoc(){
		let a = Array.prototype.slice.apply(arguments);
		a = a.map(_=>{
			if(_ instanceof Object) return JSON.stringify(_);
			return _;
		})
		cd.innerHTML += `<br />${a.join(', ')}`;
		console.log(arguments);
	}
	ptoc("connecting...");
	const socket = io({transports:["websocket"]});
	socket.on("connect", (data)=>{
		ptoc("connected", data);
	});
	socket.on("disconnect", (data)=>{
		ptoc("disconnected", data);
	});
	socket.on("news", (data)=>{
		ptoc("news...", data);
	});
	socket.emit("ack-message", "hey yo!", function(ackmsg){
		console.log("ACK::"+ackmsg);
	});
</script>
</body>
</html>